{# 继承模板文件 #}
{% extends 'common/base.html' %}

{# 加载静态文件 #}
{% load staticfiles %}

{# 修改主体部分 #}
{% block main %}
<article class="post post-{{ post_detail.pk }}">
    <header class="entry-header">
        <h1 class="entry-title">{{ post_detail.title }}</h1>
        <div class="entry-meta">
            <span class="post-category"><a href="#">{{ post_detail.cag.name }}</a></span>
            <span class="post-date"><a href="#"><time class="entry-date"
                                                      datetime="{{ post_detail.created_time }}">{{ post_detail.created_time }}</time></a></span>
            <span class="post-author"><a href="#">{{ post_detail.author }}</a></span>
            <span class="comments-link"><a href="#">4 评论</a></span>
            <span class="views-count"><a href="#">{{ post_detail.look }} 阅读</a></span>
        </div>
    </header>
    <div class="entry-content clearfix">
        {{ post_detail.body|safe }}
    </div>
</article>
<section class="comment-area" id="comment-area">
    <hr>
    <h3>发表评论</h3>
    <form action="{% url 'comment:post' post_detail.pk %}" method="post" class="comment-form">
        {% csrf_token %}
        <div class="row">
            <div class="col-md-4">
                <label for="{{ form.name.id_for_label }}">名字：</label>
                {{ form.name }}
                {{ form.name.errors }}
            </div>
            <div class="col-md-4">
                <label for="{{ form.email.id_for_email }}">邮箱：</label>
                {{ form.email }}
                {{ form.email.errors }}
            </div>
            <div class="col-md-4">
                <label for="{{ form.link.id_for_link }}">网址：</label>
                {{ form.link }}
                {{ form.link.errors }}
            </div>
            <div class="col-md-12">
                <label for="{{ form.content.id_for_content }}">评论：</label>
                {{ form.content }}
                {{ form.content.errors }}
                <button type="submit" class="comment-btn">发表</button>
            </div>
        </div>    <!-- row -->
    </form>
    <div class="comment-list-panel">
        <h3>评论列表，共 <span>{{ comment_list.count }}</span> 条评论</h3>
        <ul class="comment-list list-unstyled">
            {% for comment in comment_list %}
            <li class="comment-item">
                <span class="nickname">{{ comment.name }}</span>
                <time class="submit-date" datetime="{{ comment.created_time }}">{{ comment.created_time }}</time>
                <div class="text">
                    {{ comment.content }}
                </div>
            </li>
                {% empty %}
                暂无评论
            {% endfor %}
        </ul>
    </div>
</section>
{% endblock main %}
{% block toc %}
<div class="widget widget-content">
    <h3 class="widget-title">文章目录</h3>
    <ul>
        <li>
            <a href="{% url 'blog:detail' post_detail.pk %}">{{ post_detail.toc|safe }}</a>
        </li>
    </ul>
</div>
{% endblock toc %}

{% block tag %}
<div class="widget widget-tag-cloud">
    <h3 class="widget-title">标签云</h3>
    <ul>
        {% for tag in post_detail.tag.all %}
        <li>
            <a href="{% url 'blog:tag' tag.pk %}">{{ tag.name }}</a>
        </li>
        {% endfor %}
    </ul>
</div>
{% endblock tag %}
